<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2.6.v-bind指令</title>
    <style>
        .active {
            border: 5px solid red;
        }
    </style>
    <script src="vue.js"></script>
</head>

<body>
    <div id="app">
        <img v-bind:src="imgSrc" alt="">
        <br>
        三元表达式添加类名方法 :class="isActive?'active':''"
        <img :src="imgSrc" alt="" :title="imgTitle+'点击切换'" :class="isActive?'active':''" @click="toggleActive">
        <br>
        对象方式添加类名方法 :class="{active:isActive}"（推荐）
        <img :src="imgSrc" alt="" :title="imgTitle+'点击切换'" :class="{active:isActive}" @click="toggleActive">
    </div>
    <script>
        let app = new Vue({
            el: "#app",
            data: {
                imgSrc: "images/1.jpg",
                imgTitle: "数码宝贝",
                isActive: true,
            },
            methods: {
                toggleActive: function () {
                    this.isActive = !this.isActive;
                }
            },
        })
    </script>
</body>

</html>